//
//  RankingViewController.swift
//  SLQuickReader
//
//  Created by ALin on 2017/8/2.
//  Copyright © 2017年 ALin. All rights reserved.
//

import UIKit

class RankingViewController: BaseViewController {
    private let viewModel = RankingViewModel()
    override func viewDidLoad() {
        super.viewDidLoad()
        
        automaticallyAdjustsScrollViewInsets = false
        
        setupContent()
    }
    
    
    fileprivate func setupContent(){
        view.addSubview(rankingHeader)
        rankingHeader.snp.makeConstraints{
            $0.left.right.equalTo(0)
            $0.height.equalTo(40)
            $0.top.equalTo(64)
        }
        
        let left = RankingLeftController()
        addChildViewController(left)
        view.addSubview(left.view)
        
        left.view.snp.makeConstraints { (make) in
            make.left.bottom.equalTo(0)
            make.top.equalTo(rankingHeader.snp.bottom)
            make.width.equalTo(80)
        }
        
        let right = RankingRightController()
        addChildViewController(right)
        view.addSubview(right.view)
        
        right.view.snp.makeConstraints { (make) in
            make.right.bottom.equalTo(0)
            make.left.equalTo(left.view.snp.right)
            make.top.equalTo(rankingHeader.snp.bottom)
        }
        
        viewModel.bind(to: left.tableView, right.tableView, rankingHeader)
    }
    
    private lazy var rankingHeader: RankingHeader = {
        let header = (RankingHeader.loadNib() as! RankingHeader).then{
            $0.backgroundColor = UIColor.white
        }
        return header
    }()
    
}
